package org.example.order.service.converter;

import org.example.order.domain.Order;
import org.example.order.domain.OrderDetail;
import org.example.order.domain.Org;
import org.example.order.domain.Product;
import org.example.order.service.dto.OrderDTO;
import org.example.order.service.dto.OrderDetailDTO;
import org.example.order.service.dto.OrgDTO;
import org.example.order.service.dto.ProductDTO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

@Mapper
public interface OrderConverter {
    OrderConverter INSTANCE = Mappers.getMapper(OrderConverter.class);

    @Mapping(expression = "java(order.getTotalAmount().isPresent() ? order.getTotalAmount().get() : null)", target = "totalAmount")
    OrderDTO convert(Order order);

    OrderDetailDTO convert(OrderDetail orderDetail);

    OrgDTO convert(Org org);

    ProductDTO convert(Product product);
}
